<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;

class insertAkbusHoliday extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'insertAkbusHoliday';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '写入假日数据';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return void
     */
    public function handle(): void
    {
        $festival = [
            '2020-01-01',
            '2020-01-24',
            '2020-01-25',
            '2020-01-26',
            '2020-04-04',
            '2020-05-01',
            '2020-06-25',
            '2020-10-01',
            '2020-10-02',
            '2020-10-03',
            '2020-10-04'
        ];
        foreach ($festival as $k=> $date) {
            $data = DB::table('akbus_holiday')->insert(
                ['holiday_date' => $date]
            );
            if ($data) {
                $this->info($k.'- Insert Success' . PHP_EOL);
            }
        }
    } 
    
}
